/***************************************************************************
创建者：朱志平
 开始时间：               : 2016.12.02
 copyright            : (C) 同川科技
 修改说明：（每次有修改就添加一条，带有 修改人，修改时间，修改描述）

 ***************************************************************************
 *   更新程序、恢复出厂设置视窗测试用代理类
*                                                                         *
 ***************************************************************************/
#include "updateprogramdelegate.h"


UpdateProgramDelegate::UpdateProgramDelegate(QWidget *parent):
        QObject(parent)
{
}

void UpdateProgramDelegate::initialView()
{
    updateProgramView->uDiskLocation = "./";
    updateProgramView->hmiProgram = "hmi";
    updateProgramView->controllerProgram = "controller";

    updateProgramView->updateView();
}

void UpdateProgramDelegate::updateHmiProgramSlot(QString hmiProgram)
{
    qDebug() << "update Hmi Program:" << hmiProgram;

    QString message;
    if(hmiProgram.isEmpty())
    {
        message = "更新示教器程序失败" ;
    }
    else
    {
        message = "更新示教器程序成功\n" + hmiProgram;
    }
    updateProgramView->returnMessage(message);
}

void UpdateProgramDelegate::updateControllerProgramSlot(QString controllerProgram)
{
    qDebug() << "update Controller Program:" << controllerProgram;

    QString message;
    if(controllerProgram.isEmpty())
    {
        message = "更新控制器程序失败" ;
    }
    else
    {
        message = "更新控制器程序成功\n" + controllerProgram ;
    }
    updateProgramView->returnMessage(message);
}

void UpdateProgramDelegate::restoreHmiFactoryProgramSlot()
{
    qDebug() << "restore Hmi FactoryProgram";

    QString message = "恢复示教器程序出厂状态成功";
    updateProgramView->returnMessage(message);
}

void UpdateProgramDelegate::restoreControllerFactoryProgramSlot()
{
    qDebug() << "restore Controller FactoryProgram";

    QString message = "恢复控制器程序出厂状态成功";
    updateProgramView->returnMessage(message);
}
